<?php
include("include/conn.php");
require('include/Smarty/libs/Smarty.class.php');
$billNum  = 1;
if(isset($_POST['insertBtn']))
{
  $insertQueryaavakvoucher = "INSERT INTO aavakvoucher (billNo,date,drCr,partyName,silver,touch,weight,labour,amount)
                               VALUE ('".$_POST['billNo']."','".$_POST['dateYear']."-".$_POST['dateMonth']."-".$_POST['dateDay']."','".$_POST['drCr']."','".$_POST['partyName']."',
                                      '".$_POST['silver']."','".$_POST['touch']."','".$_POST['weight']."','".$_POST['labour']."','".$_POST['amount']."')";
  $insertQueryaavakvoucherRes = mysql_query($insertQueryaavakvoucher);
  
  if(!$insertQueryaavakvoucherRes)
    die("Insert Query Not Inserted : ".mysql_error());
  else
  {
    header("Location: aavakVoucherList.php");
  }
}
  // This for select billBook No. : Start
  $selectBillNo = "SELECT billNo FROM aavakvoucher
                 ORDER BY aavakvoucherId DESC";
  $selectBillNoRes = mysql_query($selectBillNo);
  if($billNoRow = mysql_fetch_assoc($selectBillNoRes))
    if($billNoRow['billNo'] == 100)
      $billNum = 1;
    else
      $billNum = (int)$billNoRow['billNo'] + 1;
  // This for select billBook No. : End

$smarty = new Smarty;
require("bottom.php");
$smarty->assign("billNum",$billNum);
$smarty->display("aavakVoucher.tpl");
?>